const postsModel=require('../model/posts')
const categoryModel=require('../model/category')
module.exports={
    getFrontSideIndexpage(req,res){
        res.render('index');
    },
    getFrontSideDetailpage(req,res){
        res.render('detail');
    },
    getFrontSideListpage(req,res){
        res.render('list');
    },
    getLastedPosts(req,res){
        postsModel.getLastedPosts(data=>{
            let respones=data instanceof Array?{code:200,msg:'获取成功',data}:{code:'500',msg:'获取失败'};
            res.send(respones);
        })
    },
    getNavigatorList(req,res){
        categoryModel.getNavigatorList(data=>{
             let response=data instanceof Array ?{code:200,msg:'ok',data}:{code:500,msg:'获取失败'};
           res.send(response)
        })
    },
    getPostsByCategoryId(req,res){
        let {id,pageIndex}=req.query;
        postsModel.getPostsByCategoryId(id, pageIndex, data => {
            let respones=data instanceof Array?{code:200,msg:'获取成功',data}:{code:'500',msg:'获取失败'};
            res.send(respones);
        })
    }
}